package com.bokesoft.yes.mid.session;

import com.bokesoft.yes.mid.auth.cache.Counter;
import com.bokesoft.yes.mid.base.MidVE;
import com.bokesoft.yes.mid.connection.dbmanager.PSArgs;
import com.bokesoft.yigo.meta.dataobject.MetaColumn;
import com.bokesoft.yigo.meta.dataobject.MetaTable;
import com.bokesoft.yigo.mid.base.DefaultContext;
import com.bokesoft.yigo.mid.connection.IDBManager;
import com.bokesoft.yigo.mid.session.ISessionInfo;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

public class UserRoleUtil {
	private String SQL_QUERY_ROLE = null;

	public void queryRoleData(DefaultContext var1, ISessionInfo var2, Long var3) throws Throwable {
//		a var4;
//		a var6;
//		(var6 = var4 = new a(this)).a = new g(var6.a);
//		if (!((MidVE) var1.getVE()).isAuthenticate() && Counter.count != 0L && Counter.passed) {
//			if (Counter.count % 10000L == 0L) {
//				var4.a(var1);
//			}
//		} else {
//			var4.a(var1);
//		}

		++Counter.count;
		IDBManager var16 = var1.getDBManager();
		MetaTable var5 = var1.getVE().getMetaFactory().getDataObject("Role").getMainTable();
		String var19 = var16.keyWordEscape(var5.getBindingDBTableName());
		String var7 = var16.keyWordEscape(var5.getOIDColumn().getBindingDBColumnName());
		String var17 = var16.keyWordEscape(((MetaColumn) var5.get("Enable")).getBindingDBColumnName());
		MetaTable var13 = var1.getVE().getMetaFactory().getDataObject("Operator").getTable("SYS_OperatorRole");
		String var8 = var16.keyWordEscape(var13.getBindingDBTableName());
		String var9 = var16.keyWordEscape(var13.getSOIDColumn().getBindingDBColumnName());
		String var14 = var16.keyWordEscape(((MetaColumn) var13.get("Role")).getBindingDBColumnName());
		StringBuffer var10;
		(var10 = new StringBuffer()).append("select ").append(var19).append(".").append(var7).append(" from ")
				.append(var19).append(" join ").append(var8).append(" on ").append(var19).append(".").append(var7)
				.append(" = ").append(var8).append(".").append(var14).append(" where ").append(var8).append(".")
				.append(var9).append("=? and ").append(var19).append(".").append(var17).append("=1");
		this.SQL_QUERY_ROLE = var10.toString();
		PreparedStatement var15 = null;
		ResultSet var18 = null;
		ArrayList var20 = new ArrayList();

		try {
			var15 = var16.preparedQueryStatement(this.SQL_QUERY_ROLE);
			PSArgs var21;
			(var21 = new PSArgs()).addLongArg(var3);
			var18 = var16.executeQuery(var15, this.SQL_QUERY_ROLE, var21);

			while (var18.next()) {
				var20.add(var18.getLong(1));
			}

			var2.getRoleIDList().addAll(var20);
		} finally {
			if (var18 != null) {
				var18.close();
			}

			if (var15 != null) {
				var15.close();
			}

		}
	}
}